import tools from '../../../utils/tools'
import cartItem from '../../../template/courseItem.tpl'
import Event from './Event'
@tools //相当于给Render上面添加两个方法
export default class Render {
    constructor(oCart, courseData, cartData, observer) {
        this.oCart = oCart
        this.courseData = courseData
        this.cartData = cartData
        this.observer = observer
        this.init()
    }
    init() {
        this.render()
        new Event(this.oCart,
            this.courseData,
            this.cartData,
            this.observer)
    }
    render() {
        const oFrag = document.createDocumentFragment();
        this.cartData.forEach(item => {
            ofrag.appendChild(Render.createElement('li',

                Render.tplReplace(cartItem, {
                    id: item.id,
                    title: item.title,
                    priginPrice: item.coupon ? `<del>${item.price}</del>` : `${item.price}`,
                })))
        })
        this.oList.appendChild(oFrag)
    }
}